package design.pattern.application.CommandAndChain;

import java.util.List;

/**
 * @program JavaBase
 * @description:
 * @author: zhanglu
 * @create: 2020-05-22 14:36:00
 */
public class LsCommand extends Command{

    @Override
    public String execute(CommandVo vo) {
        List<? extends CommandName> commandNameList = super.buildChain(AbstractLs.class);
        CommandName firstNode = firstNode(commandNameList);
        return firstNode.handleMessage(vo);
    }

    public CommandName firstNode(List<? extends CommandName> commandNameList){
        CommandName c1 = commandNameList.get(0);
        CommandName c2 = commandNameList.get(1);
        CommandName c3 = commandNameList.get(2);
        c2.setNext(c3);
        c1.setNext(c2);
        return c1;
    }

}